Repository navigation
MCP client: record what read_resource returns as observed input (carries #689, closes #667) - #776
Merged
Merged
Conversation
… an observed input (#667) Signed-off-by: Mr45401 <185895283+Mr45401@users.noreply.github.com>
Signed-off-by: Mr45401 <185895283+Mr45401@users.noreply.github.com>
Signed-off-by: Mr45401 <185895283+Mr45401@users.noreply.github.com>
Signed-off-by: LoopGlitch26 <53336715+LoopGlitch26@users.noreply.github.com>
read_resource repeated _list's body (fetch, unnamed-server warning, observe, fail-mode branch). One helper, _observed, now takes the session method and the source suffix, so the fail-closed path lives in one place. A resource over half a signer frame is now recorded as its digest, as a list's page is, rather than sent whole and refused by the signer. Signed-off-by: LoopGlitch26 <53336715+LoopGlitch26@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Carries #689 by @Mr45401:
read_resourceon a wrapped MCPClientSession(and undertracekit.instrument()) records what it returns as untrusted observed input,mcp:<server>/resource, and withholds a resource the signer can't record unless the run fails open. Closes #667.Their four commits are in this branch unchanged (authorship and sign-offs kept). A push to their branch was refused (the git-lfs lock check needs push access to their fork), so the rest is on top here:
InputRequiredRoundsandBigListstests restore the methodsinstrument()patches;read_resourceis one of them now, so it's in their lists too, or it would stay patched for later tests.read_resourcerepeated_list's body line for line;_observed(method, kind)now holds the fetch, the unnamed-server warning,observeand the fail-mode branch, andread_resourceand the three lists are one line each. With it a resource over half the signer's 1 MiB frame is recorded as itssha256:digest, as a list's page is (Integrations: MCP big lists and input-required rounds, LangChain parallel asks, tracekit last, gateway listing errors #753), instead of being sent whole and refused. New test:test_a_resource_over_half_a_frame_is_recorded_as_its_digest, which fails before the change.docs/integrations/mcp.mdsays so.How it was run
In a sealed container (no network), on this head:
pyflakes tracekit testsclean;tests/test_contract_mcp.py,test_instrument.py,test_agent_framework.py,test_pydantic_ai.py,test_mcp_gateway.py,test_docs.py: 117 passed, 91 skipped (the framework packages weren't installed there; CI runs them).As a user would: a real
SignerServiceand a realMCPServerwith two resources, read throughinstrument()'s wiring (autowire._mcp) withmcp.Client.read_resource. Both came back whole, and the signer holds twoinput.observedrecords,mcp:notes/resource,untrusted: the 5-character one as itself, the 1 MiB one as its digest.Closes #689 when merged (superseded).